package cn.tude.cn.tedu.cn.tedu;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;

public class Test5 {
    public static void main(String[] args) {
        Collection<Integer> a=new ArrayList();
         a.add(13);
         a.add(15);
         a.add(16);

        System.out.println(a);
        //a.clear();
     //   System.out.println(a);

        System.out.println(  a.contains(13));
        System.out.println(a.equals(13));
        System.out.println(a.hashCode());
        System.out.println(a.isEmpty());
        System.out.println(a.remove(15));
        System.out.println(a.size());
         Object[]os=a.toArray();
        System.out.println(Arrays.toString(os));

        Collection<Integer>b=new ArrayList();
        b.add(123);
        b.add(124);
        b.add(153);
        System.out.println(b);
        System.out.println(b.addAll(a));
        System.out.println(b);
        System.out.println(b.containsAll(b));
      //  System.out.println(b.removeAll(b));
      //  System.out.println(b);
        System.out.println(b.retainAll(a));
        System.out.println(a);
//Iterator<E>iterator(); 迭代集合中元素的迭代器--Iterator
        Iterator<Integer> it=a.iterator();
        while(it.hasNext()){//hasNext判断是否有元素
                  Integer in=   it.next();
            System.out.println(in);


        }



    }
}

